package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Tutorrequest;
import com.ruoyi.system.service.ITutorrequestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家教申请综合Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/system/tutorrequest")
public class TutorrequestController extends BaseController
{
    @Autowired
    private ITutorrequestService tutorrequestService;

    /**
     * 查询家教申请综合列表
     */
    // @PreAuthorize("@ss.hasPermi('system:tutorrequest:list')")
    @GetMapping("/list")
    public TableDataInfo list(Tutorrequest tutorrequest)
    {
        startPage();
        List<Tutorrequest> list = tutorrequestService.selectTutorrequestList(tutorrequest);
        return getDataTable(list);
    }

    /**
     * 导出家教申请综合列表
     */
    // @PreAuthorize("@ss.hasPermi('system:tutorrequest:export')")
    @Log(title = "家教申请综合", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Tutorrequest tutorrequest)
    {
        List<Tutorrequest> list = tutorrequestService.selectTutorrequestList(tutorrequest);
        ExcelUtil<Tutorrequest> util = new ExcelUtil<Tutorrequest>(Tutorrequest.class);
        util.exportExcel(response, list, "家教申请综合数据");
    }

    /**
     * 获取家教申请综合详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:tutorrequest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tutorrequestService.selectTutorrequestById(id));
    }

    /**
     * 新增家教申请综合
     */
    // @PreAuthorize("@ss.hasPermi('system:tutorrequest:add')")
    @Log(title = "家教申请综合", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Tutorrequest tutorrequest)
    {
        return toAjax(tutorrequestService.insertTutorrequest(tutorrequest));
    }

    /**
     * 修改家教申请综合
     */
    // @PreAuthorize("@ss.hasPermi('system:tutorrequest:edit')")
    @Log(title = "家教申请综合", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Tutorrequest tutorrequest)
    {
        return toAjax(tutorrequestService.updateTutorrequest(tutorrequest));
    }

    /**
     * 删除家教申请综合
     */
    // @PreAuthorize("@ss.hasPermi('system:tutorrequest:remove')")
    @Log(title = "家教申请综合", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tutorrequestService.deleteTutorrequestByIds(ids));
    }
}
